<template>
    <div class="zhuti">
      <div class="box">
        <div class="boxInput">
        <div class="rig">
          <div>权限ID：</div>
          <div>
          <el-input v-model="input" placeholder="请输入权限名称" />
      </div>
      <el-button class="sou"  :loading="true" >搜索</el-button>
        </div>
    </div>
      </div>
      <div class="buttom">
       <div class="header"> 
              <div class="left" @click="openn">删除<span v-show="(num!==0)">x{{num}}</span></div>
          </div>
          <div class="Tab">
            <el-table :data="tableData" style="width: 100%" height="55vh"   @selection-change="selevChang" :header-cell-style="{background:'#f5f5f5'}" >
      <el-table-column type="selection" width="55" />
      <el-table-column prop="name" label="用户" min-width="120"  cl ass="TableC"/>
      <el-table-column prop="state" label="角色" min-width="120" />
      <el-table-column prop="city" label="手机号" min-width="120" />
      <el-table-column prop="address" label="状态" min-width="300" />
      <el-table-column prop="zip" label="密码" min-width="120" />
      <el-table-column prop="zip" label="评价时间" min-width="120" />
      <el-table-column fixed="right" label="操作" min-width="90">
        <template #default="scopee">
            <div class="bbox">
                <el-tooltip content="是否升为超级管理员"   placement="top" >
            <div class="reply" @click="afterSales(scopee)"><el-icon><Top /></el-icon></div>
            </el-tooltip>
                <el-tooltip content="删除"   placement="top" >
            <div class="reply" @click="huifu(scopee)"><el-icon><Delete /></el-icon></div>
            </el-tooltip>
        </div>
        </template>
      </el-table-column>
    </el-table>
          </div>
          <div class="paging">
          <el-pagination
      v-model:current-page="currentPage4"
      v-model:page-size="pageSize4"
      :page-sizes="[10,20,30,50 ]"
      :background="true"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
          </div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from "vue";
  import { ElMessage, ElMessageBox } from 'element-plus'
  const input = ref("");
  const currentPage4 = ref(1)
  const pageSize4 = ref(10) 
  let num = ref(0)
  const tableData = [
    {
      date: '2016-05-03',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      tag: 'Home',
    },
    {
      date: '2016-05-02',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      tag: 'Office',
    },
    {
      date: '2016-05-04',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      tag: 'Home',
    },
    {
      date: '2016-05-01',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      tag: 'Office',
    },
  ]
//   多选框
  function selevChang (row){
         console.log(row);
         num.value= row.length
  }
  function handleSizeChange(){
    console.log(`显示几行`);
}
// 页面改变
function  handleCurrentChange(p){
    console.log(`页数改变`,p);
}
//   多选删除
const openn = () => {
  
  if(num.value==0){
      ElMessage({
      type: 'info',
      message: '请勾选需要删除的数据',
    })
  }else{
      ElMessageBox.confirm(
  '请确定是否删除？',
  'Warning',
  {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  }
)
  .then(() => {
    ElMessage({
      type: 'success',
      message: '删除成功',
    })
  })
  .catch(() => {
    ElMessage({
      type: 'info',
      message: '已取消删除',
    })
  })
  }

}
//  删除
function huifu(row){
    console.log(111,row.$index);
    ElMessageBox.confirm(
    '请确定是否删除？',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      ElMessage({
        type: 'success',
        message: '删除成功',
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '已取消删除',
      })
    })
}
// 超级管理员
function afterSales (row){
    ElMessageBox.confirm(
    '确定是否提升超级管理员？',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      ElMessage({
        type: 'success',
        message: '提升成功',
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '已取消提升',
      })
    })
}
  </script>
  
  <style scoped>
  .zhuti{
      background-color: #f5f5f5; 
  }
  .box{
      display: flex;
      justify-content: space-between;
  }
  .box>.left{
      margin-top: 10px;
      width: 50%;
      line-height: 40px;
      display:flex;
      justify-content: space-around;
      border-bottom: 1px solid black;
  }
  .boxInput>.rig{
      line-height: 40px;
      height: 40px;
      display:flex;
     border-radius: 5px;
     font-size: 14px;
  }
  .boxInput{
    width: 100%;
    margin-top: 10px;
    /* height: 76px; */
    padding: 15px 10px;
    border-radius: 10px;
    background-color: white;
  }
  .sou{
      margin-top: 7px;
      width: 70px;
      height: 32px;
      line-height: 30px;
      font-size: 12px;
      background-color: #ff6a6c;
      text-align: center;
      border-radius: 5px;
      margin-left: 10px;
      color: white;
  }
  .left>p>span{
      
      background-color: #ff6a6c;
      border-radius: 100px;
      padding: 2px 5px;
      font-size: 10px;
  }
  .buttom{
      margin-top: 30px;
      background-color:white;
      border-radius: 10px;
  }
  .header{
      padding: 10px 20px;
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
  }
  .header>div{
      padding: 5px 0px;
        width: 80px;
       text-align: center;
       border-radius: 5px;
  }
  .header>.left{
    height: 27px;
      background-color: #7e6aff;
      color:white;
  }
  /* .header>.rig{
      display: flex;
      justify-content: center;
      text-align: center;
      background-color: #ffa66a;
  }
  .header>.rig>div{
      font-size: 20px;
      margin-right: 3px;
  } */
  .bbox{
    display: flex;
    padding: 30px 0;
  }
  .reply{
    width: 30px;
    height: 30px;
    line-height: 30px;
    border: 1px solid black;
    border-radius: 50%;
    font-size: 20px;
    text-align: center;
    margin-left: 5px;
    border: 1px #a9acb1 solid;

  }
  .reply:hover{
    background-color: #ff6a6c;
    color: white;
  }
 .paging{
    width: 100%;
    position: fixed;
    bottom: 20px;
 }
  </style>
  